<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="javax.jdo.PersistenceManager" %>
<%@ page import="com.google.appengine.api.users.User" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<%@page import="br.com.fiap.goaround.bo.TrafficBO"%>
<%@page import="br.com.fiap.goaround.to.TrafficTO"%><html>
  <body>
(data: 17/10/2009 hora: 15:25)

<%
    UserService userService = UserServiceFactory.getUserService();
    User user = userService.getCurrentUser();
    TrafficBO trs = new TrafficBO();
    try{
    List<TrafficTO> enderecos = new ArrayList<TrafficTO>();
    enderecos = trs.findAll();
    Iterator it = enderecos.iterator();
    if (it.hasNext()) {
%>
<p><font size="6" face="Verdana"><b>Base de Endereços</b></font></p>
<table border="1" cellspacing="0" cellpadding="2" bordercolor="666633">
<tr>
<td><b>ID</b></td>
<td><b>Endereço</b></td>
<td><b>Status</b></td>
<td><b>Longitude</b></td>
<td><b>Latitude</b></td>
<td><b>Ultima Atualização</b></td>
</tr>
<%
     while (it.hasNext()) {
    	 TrafficTO tra = new TrafficTO();
    	 tra = (TrafficTO) it.next();
    	 if(tra.getEndereco() == null){
    	 }
    	 else{
%>
<tr>
<td><%= tra.getId() %></td>
<td><%= tra.getEndereco() %></td>
<td><%= tra.getStatus() %></td>
<td><%= tra.getLongitude() %></td>
<td><%= tra.getLatitude() %></td>
<td><%= tra.getDataInclusao() %></td>
</tr>
<%
    	 }
     }
    } else {
%>
<p>Não foi encontrado registros na base! (data: 17/10/2009 hora: 15:25)</p>
<%
    }
    } catch(Exception e){
%>
<p>Problema de acesso na base: <% e.printStackTrace(); %> (data: 17/10/2009 hora: 15:25)</p>  
<%  	
    } finally{
    	//trs.closeConnection();
    }
    
    
%>
</table>
</body>
</html>